package thread;

import java.util.stream.IntStream;

/**
 * @author Darkness Shadow
 * @description:
 * @date 2020/1/5 23:18
 */
public class Demo {
    private final static String PREFIX = "ALEX-";

    public static void main(String[] args) {
//        createThread(1).start();
//        createThread(2).start();
//        createThread(3).start();
//        createThread(4).start();

        IntStream.range(0,5).mapToObj(Demo::createThread).forEach(Thread::start);
    }

    public static void anonymous(){
        IntStream.range(0, 5).boxed().map(i ->
                new Thread(() ->
                        System.out.println(Thread.currentThread().getName())))
                .forEach(Thread::start);
    }

    private static Thread createThread(final int intName){
        return new Thread(() ->
                System.out.println(Thread.currentThread().getName()), PREFIX + intName);
    }
}
